<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<html:html>
<head>
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Cache-Control content=no-cache>
<META http-equiv=Expires content=0>
<title><bean:message key="F0505.title"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../../resource/css/style.css" type="text/css">
<script language="javascript" type="text/javascript" src="../../resource/js/util.js"></script>
<script language="javascript" type="text/javascript" src="../../resource/js/AdyhUtil.js"></script>
<script language="javascript" type="text/javascript" src="../../resource/calendar/DCDA_C03.js"></script>
<script language="javascript" type="text/javascript" src="<%=request.getContextPath()%>/resource/js/Validator.js"></script>	
<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/ext-all.js"></script>
<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/style/scripts/util.js"></script>
<script language="javascript1.2">

/**重置*/
function ResetMe()
{	
    document.getElementById("contractNumber").className = "MyText";
    document.getElementById("invoiceNumber").className = "MyText";
    document.getElementById("supplierName").className = "MyText";
	document.getElementById("totalAmount").className = "MyText";
	document.getElementById("invoiceDate").className = "MyText";
	document.getElementById("estiPayDate").className = "MyText";
	document.getElementById("realPayDate").className = "MyText";
	document.getElementById("manufacturingOrder").className = "MyText";

	var objPrompt = document.getElementById("divPrompt");
    objPrompt.style.display = "none";
	objPrompt.innerHTML = "";
}

//保存 判断
function operation1(){
	ResetMe();
	var manufacturingOrder = document.getElementById("manufacturingOrder").value;
	var contractNumber = document.getElementById("contractNumber").value;
	var invoiceNumber = document.getElementById("invoiceNumber").value;
	var supplierName = document.getElementById("supplierName").value;
	var totalAmount = document.getElementById("totalAmount").value;
	var invoiceDate = document.getElementById("invoiceDate").value;
	var estiPayDate = document.getElementById("estiPayDate").value;
	var realPayDate = document.getElementById("realPayDate").value;
	
	var submitFlag = true;
	var objPrompt = document.getElementById("divPrompt");
    objPrompt.style.display = "block";
    objPrompt.innerHTML = "";
    
    	if(!isNotNull(Jtrim(manufacturingOrder))){
			objPrompt.innerHTML += "<li><bean:message key="common.ManufacturingOrder"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("manufacturingOrder").className = "MyControlError";
			submitFlag = false;
		}
		else{
			if(isNumber(manufacturingOrder)){
				objPrompt.innerHTML += "<li><bean:message key="common.ManufacturingOrder"/><bean:message key="adyh.error.number"/>！";
				document.getElementById("manufacturingOrder").className = "MyControlError";
				submitFlag = false;
			}
		}
		
    	if(!isNotNull(Jtrim(contractNumber))){
			objPrompt.innerHTML += "<li><bean:message key="F05.contractNumber"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("contractNumber").className = "MyControlError";
			submitFlag = false;
		}
		else{
			if(isNumber(contractNumber)){
				objPrompt.innerHTML += "<li><bean:message key="F05.contractNumber"/><bean:message key="adyh.error.number"/>！";
				document.getElementById("contractNumber").className = "MyControlError";
				submitFlag = false;
			}
		}
    	
    	if(!isNotNull(Jtrim(invoiceNumber))){
			objPrompt.innerHTML += "<li><bean:message key="F05.invoiceNumber"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("invoiceNumber").className = "MyControlError";
			submitFlag = false;
		}
		else{
			if(isNumber(invoiceNumber)){
				objPrompt.innerHTML += "<li><bean:message key="F05.invoiceNumber"/><bean:message key="adyh.error.number"/>！";
				document.getElementById("invoiceNumber").className = "MyControlError";
				submitFlag = false;
			}
		}
 
	    if(!isNotNull(Jtrim(supplierName))){
			objPrompt.innerHTML += "<li><bean:message key="adyh.supplierName"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("supplierName").className = "MyControlError";
			submitFlag = false;
		}
		
		if(!isNotNull(Jtrim(totalAmount))){
			objPrompt.innerHTML += "<li><bean:message key="F0505.payMoney"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("totalAmount").className = "MyControlError";
			submitFlag = false;
		}
		else{
			if(isNumber(totalAmount)){
				objPrompt.innerHTML += "<li><bean:message key="F0504.collectMoney"/><bean:message key="adyh.error.number"/>！";
				document.getElementById("totalAmount").className = "MyControlError";
				submitFlag = false;
			}
		}
		
		if(!isNotNull(Jtrim(invoiceDate))){
			objPrompt.innerHTML += "<li><bean:message key="F0503.invoicedDate"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("invoiceDate").className = "MyControlError";
			submitFlag = false;
		}
		if(!isNotNull(Jtrim(estiPayDate))){
			objPrompt.innerHTML += "<li><bean:message key="F0505.estiPayDate"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("estiPayDate").className = "MyControlError";
			submitFlag = false;
		}
		if(!isNotNull(Jtrim(realPayDate))){
			objPrompt.innerHTML += "<li><bean:message key="F0505.realPayDate"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("realPayDate").className = "MyControlError";
			submitFlag = false;
		}

		if(submitFlag==true){
		   if(document.forms[0].layOutType.value=="add"){
	           operation('insert');
	       }else{
	           operation('update');
	       }	
		}	      
}
//动态加载 ---------------------------------------------------------------------begin
function FiltSupplier(obj)
  {  	
  		var strValue = Jtrim(obj.value);   
		if(strValue==""){
			return ;
		}
  		if(event.keyCode==38||event.keyCode==40||event.keyCode==13){
			keyEnter();
			if(numsup>=0&&(event.keyCode==38||event.keyCode==40)){
				document.getElementById("row"+numsup).focus();
				document.getElementById("row"+numsup).scrollIntoView(false);
			}
			return;
		}
		
		var strId =  obj.name; //supplierName
		  
		//回显的编码的字段名称
		var strCode = "";
		//回显的名称的字段名称
		var strName = "";
		//相应的div的名称

		var strObj = "rtnList";
		strTextName=strId
		
		strCode = "supplierCode";
		strName = "supplierName";
		//strObj = "supplier";
		 
   		Ext.Ajax.request(
   		{
		url : 'F0505.do' , 
		params : {operationType:'ajax',id:strId,name:strValue},
		method: 'POST',
		success: function ( result, request) 
			{
			var listArray = new Array();
			var obj= Ext.decode(result.responseText) ;
			var objPrompt = document.getElementById(strObj);			
			objPrompt.style.display = "block";		
			objPrompt.innerHTML = "";	
			initPosition(strObj);		
			listArray = obj.data.list;
			
			var inn = "<table WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\" bgcolor=\"#FFFFFF\" id=\"sup\" class=\"ListBackground\">";
 	        for (i=0; i<listArray.length; i++){
				inn += "<tr class=\"ListRow1\" height=\"20\" id=\"row"+(i)+"\"  onClick=\"javascript:show('"+strObj+"','"+listArray[i][0]+"','"+strCode+"','"+listArray[i][1]+"','"+strName+"')\">";
				inn += "<td>";
				inn += listArray[i][1];
				inn += "</td>";
				inn += "</tr>";
			}
			inn+="</table>";
			
			rownum=i;//获取动态加载的行数
			//若检索的结果是空，关闭div
			if(listArray.length==1&&listArray[0][0]==""&&listArray[0][1]==""){
				inn = "";
				
			}
			
			objPrompt.innerHTML += inn;
			if(rownum>0&&inn!=""){
				document.getElementById("row0").focus();
			}
			FocusTableRow1("sup",0);//鼠标划过变色
			setPosition(strObj,strName);	//设置div的位置	
			
			},	
		failure: function ( result, request) { 
			alert("<bean:message key="F020106.title"/>");
			} 
		}
		);
  }
  
  //初始化div的位置
  function initPosition(strObj){
	var objPrompt = document.getElementById(strObj);
	objPrompt.style.top=0;
	objPrompt.style.left=0;
  }
  
  //设置div的位置
  function setPosition(strObjPrompt,strObjText){
  	var objPrompt = document.getElementById(strObjPrompt);
	var objText = document.getElementById(strObjText);
	objPrompt.style.top = 20-(objPrompt.offsetTop-objText.offsetTop);
	objPrompt.style.left = objText.offsetLeft-18;
  }
  
  //设置div的位置
  function initColumn(){
 
	strCode = "supplierCode";
	strName = "supplierName";
  	document.getElementById(strCode).value = "";
	document.getElementById(strName).value = "";
  }
//----------------------------------------------------------------------end
function editInit(){
	if(document.forms[0].operationType.value == "edit"){
		//document.forms[0].manufacturingOrder.disabled = true;
		//document.forms[0].groups.disabled = true;
	}
}

function ShowFormTitle(strTitle){
	document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"height:26px; background-position: left bottom; background-image: url(../../style/images/FormTitle_A_4.gif); background-repeat: repeat-x;\">");
	document.write("  <tr >");
	document.write("	<td style=\"width:5px; background-position: left bottom; background-image: url(../../style/images/FormTitle_A_1.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
	document.write("	<td class=\"FormTitle\" style=\"width:100%; padding-left:5px; padding-top:3px; background-position: left bottom; background-image: url(../../style/images/FormTitle_A_2.gif); background-repeat: no-repeat;\">");
	document.write("		<span id=\"spanFormTitle\" class=\"SpanTitle\">"+ strTitle +"</span>");
	document.write("	</td>");
	document.write("	<td style=\"width:5px; background-position: right bottom; background-image: url(../../style/images/FormTitle_A_3.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
    document.write("  </tr>");
	document.write("</table>");
}	

</script>
</head>

<body marginheight="0" marginwidth="0" bottommargin="0" topmargin="0" onLoad="javascript:editInit();">
<html:form method="post" action="/pages/F05/F0505.do" enctype="multipart/form-data">
<html:hidden property="operationType"/>
<html:hidden property="layOutType" />
<html:hidden property="id"/>
<html:hidden property="supplierCode" />
<!--Begin：表单标题-->
<div class="DivBlock">
	<script language="javascript" type="text/javascript">
		ShowFormTitle("<bean:message key="F0505.title"/>");
	</script>
</div>
<!--End：表单标题-->
<!--Begin：表单折叠区块1-->
<div class="DivBlock">
<div class="DivWrap">
  <table  WIDTH="81%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
	<tr>	
		<td align="right"><bean:message key="F05.contractNumber"/></td>
		<td align="left"><html:text property="contractNumber" styleClass="MyText" />
		<span class="Need">*</span></td>
		<td align="right"><bean:message key="F05.invoiceNumber"/></td>
		<td align="left"><html:text property="invoiceNumber" styleClass="MyText" />
		<span class="Need">*</span></td>		
		<td align="right"><bean:message key="common.ManufacturingOrder"/></td>
		<td align="left"><html:text property="manufacturingOrder" styleClass="MyText" />
		<span class="Need">*</span></td>		
	</tr>
	<tr>
		<td align="right"><bean:message key="adyh.supplierName"/></td>
		<td align="left"><html:text property="supplierName" styleClass="MyText" onkeyup="FiltSupplier(this)" style="position:relative"/>
		<span class="Need">*</span></td>		
		<td align="right"><bean:message key="F0505.payMoney"/></td>
		<td align="left"><html:text property="totalAmount" styleClass="MyText"/>
		<span class="Need">*</span></td>
		<td align="center">&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
	   <td align="right"><bean:message key="F0503.invoicedDate"/></td>
		<td align="left"><html:text property="invoiceDate" styleClass="MyText" onclick="return CalendarClick(this)"/>
		<span class="Need">*</span></td>
		<td align="right"><bean:message key="F0505.estiPayDate"/></td>
		<td align="left"><html:text property="estiPayDate" styleClass="MyText" onclick="return CalendarClick(this)"/>
		<span class="Need">*</span></td>
		<td align="right"><bean:message key="F0505.realPayDate"/></td>
		<td align="left"><html:text property="realPayDate" styleClass="MyText" onclick="return CalendarClick(this)"/>
		<span class="Need">*</span></td>
	</tr>
  </table>
</div>
</div>
<!--End：表单折叠区块1-->
<div class="DivBlock">
<div class="DivButton">
  <input type="button" name="Submit1" class="MyButton" value="<bean:message key="common.save"/>" onClick="javascript:operation1();">
  <input type="button" name="Submit2" class="MyButton" value="<bean:message key="common.back"/>" onClick="javascript:operation('back');">
</div>
<div class="DivPrompt" id="divPrompt" style="display:none">
</div>
</div>
<div id="supplier" style="display: black; position:relative; width:135">							
</div>
<%------------- -----------------------------------动态加载start----------------------------------------------------------------------%>
<div id="rtnList" style="display: none; position:relative; overflow:auto; width:130; height:240" onmouseleave="col(this);initColumn()">
</div>
<%------------------------------------------------动态加载end----------------------------------------------------------------------%>
</html:form>
</body>
</html:html>